*************************************************************************
*																		*
*					Campaign Panel Book Chapter 5 - Attitudes 2009		*
*																		*
*************************************************************************	


*******************************************************************************
**
** III. Mobilizing and demobilizing attitudes 
**
*******************************************************************************

use "${data}\ZA5305_en_v5-0-0.dta", clear

*------------------------------------
* Interest in the campaign
*--------------------------------------

fre kp?_390
mvdecode kp?_390, mv(6/100)
foreach welle of numlist 2/6 {
	gen wkampfint`welle'=(kp`welle'_390-1)/4
	}
tab wkampfint5 kp5_390, m

// Replace values for waves in which campaign interest was not measured

gen wkampfint1=wkampfint2
gen wkampfint7=wkampfint6

********************************************************************************
* Political attitudes


* Internal efficacy
mvdecode kp?_050?, mv(99)
foreach welle of numlist 1 4 6 7 {
	gen inteff1`welle'=(kp`welle'_050h-1)/4
	gen inteff2`welle'=(kp`welle'_050k-1)/4
	gen intefficacy`welle'=(inteff1`welle'+inteff2`welle')/2
	}
	
tab1 intefficacy1 intefficacy4 intefficacy6 intefficacy7
tabstat intefficacy1 intefficacy4 intefficacy6 intefficacy7

// Replace values for waves in which internal efficacy was not measured

gen intefficacy2 = 2/3*intefficacy1 + 1/3*intefficacy4
replace intefficacy2 = intefficacy1 if intefficacy4==.
replace intefficacy2 = intefficacy4 if intefficacy1==.

gen intefficacy3 = 1/3*intefficacy1 + 2/3*intefficacy4
replace intefficacy3 = intefficacy1 if intefficacy4==.
replace intefficacy3 = intefficacy4 if intefficacy1==.

egen intefficacy5=rowmean (intefficacy4 intefficacy6)


* External efficacy

foreach welle of numlist 1 4 6 7 {
	gen exteff1`welle'=(kp`welle'_050a-1)/4
	gen exteff2`welle'=(kp`welle'_050e-1)/4
	gen extefficacy`welle'=(exteff1`welle'+exteff2`welle')/2
	}
	
tab1 extefficacy1 extefficacy4 extefficacy6 extefficacy7
tabstat extefficacy1 extefficacy4 extefficacy6 extefficacy7

// Replace values for waves in which external efficacy was not measured

gen extefficacy2 = 2/3*extefficacy1 + 1/3*extefficacy4
replace extefficacy2 = extefficacy1 if extefficacy4==.
replace extefficacy2 = extefficacy4 if extefficacy1==.

gen extefficacy3 = 1/3*extefficacy1 + 2/3*extefficacy4
replace extefficacy3 = extefficacy1 if extefficacy4==.
replace extefficacy3 = extefficacy4 if extefficacy1==.

egen extefficacy5=rowmean (extefficacy4 extefficacy6)


* Satisfaction with democracy

tab1 kp1_020 kp7_020
tab1 kp1_020 kp7_020, nolabel
mvdecode kp?_020, mv(6/105)

foreach welle of numlist 1 3 5 7 {
	gen zufr`welle'=(5-kp`welle'_020)/4
}
	
egen zufr2=rowmean (zufr1 zufr3)
egen zufr4=rowmean (zufr3 zufr5)
egen zufr6=rowmean (zufr5 zufr7)
tabstat zufr?

*******************************************************************************
* Evaluation scales (for indifference and alienation)

tab1 kp1_430a
tab1 kp1_430a, nolabel
mvdecode kp?_430?, mv(12/110)
tab fedstate
tab fedstate, nolabel

// value range 0-1 //

tab1 kp1_430a-kp1_430f

gen skal_part_a1=(kp1_430a-1)/10
gen skal_part_b1=(kp1_430b-1)/10
gen skal_part_c1=(kp1_430c-1)/10
gen skal_part_d1=(kp1_430d-1)/10
gen skal_part_e1=(kp1_430e-1)/10
gen skal_part_f1=(kp1_430f-1)/10

gen skal_part_a2=(kp2_430a-1)/10
gen skal_part_b2=(kp2_430b-1)/10
gen skal_part_c2=(kp2_430c-1)/10
gen skal_part_d2=(kp2_430d-1)/10
gen skal_part_e2=(kp2_430e-1)/10
gen skal_part_f2=(kp2_430f-1)/10

gen skal_part_a3=(kp3_430a-1)/10
gen skal_part_b3=(kp3_430b-1)/10
gen skal_part_c3=(kp3_430c-1)/10
gen skal_part_d3=(kp3_430d-1)/10
gen skal_part_e3=(kp3_430e-1)/10
gen skal_part_f3=(kp3_430f-1)/10

gen skal_part_a4=(kp4_430a-1)/10
gen skal_part_b4=(kp4_430b-1)/10
gen skal_part_c4=(kp4_430c-1)/10
gen skal_part_d4=(kp4_430d-1)/10
gen skal_part_e4=(kp4_430e-1)/10
gen skal_part_f4=(kp4_430f-1)/10

gen skal_part_a5=(kp5_430a-1)/10
gen skal_part_b5=(kp5_430b-1)/10
gen skal_part_c5=(kp5_430c-1)/10
gen skal_part_d5=(kp5_430d-1)/10
gen skal_part_e5=(kp5_430e-1)/10
gen skal_part_f5=(kp5_430f-1)/10

gen skal_part_a6=(kp6_430a-1)/10
gen skal_part_b6=(kp6_430b-1)/10
gen skal_part_c6=(kp6_430c-1)/10
gen skal_part_d6=(kp6_430d-1)/10
gen skal_part_e6=(kp6_430e-1)/10
gen skal_part_f6=(kp6_430f-1)/10

gen skal_part_a7=(kp7_430a-1)/10
gen skal_part_b7=(kp7_430b-1)/10
gen skal_part_c7=(kp7_430c-1)/10
gen skal_part_d7=(kp7_430d-1)/10
gen skal_part_e7=(kp7_430e-1)/10
gen skal_part_f7=(kp7_430f-1)/10


replace skal_part_a1=round(skal_part_a1,.1)
replace skal_part_b1=round(skal_part_b1,.1)
replace skal_part_c1=round(skal_part_c1,.1)
replace skal_part_d1=round(skal_part_d1,.1)
replace skal_part_e1=round(skal_part_e1,.1)
replace skal_part_f1=round(skal_part_f1,.1)

replace skal_part_a2=round(skal_part_a2,.1)
replace skal_part_b2=round(skal_part_b2,.1)
replace skal_part_c2=round(skal_part_c2,.1)
replace skal_part_d2=round(skal_part_d2,.1)
replace skal_part_e2=round(skal_part_e2,.1)
replace skal_part_f2=round(skal_part_f2,.1)

replace skal_part_a3=round(skal_part_a3,.1)
replace skal_part_b3=round(skal_part_b3,.1)
replace skal_part_c3=round(skal_part_c3,.1)
replace skal_part_d3=round(skal_part_d3,.1)
replace skal_part_e3=round(skal_part_e3,.1)
replace skal_part_f3=round(skal_part_f3,.1)

replace skal_part_a4=round(skal_part_a4,.1)
replace skal_part_b4=round(skal_part_b4,.1)
replace skal_part_c4=round(skal_part_c4,.1)
replace skal_part_d4=round(skal_part_d4,.1)
replace skal_part_e4=round(skal_part_e4,.1)
replace skal_part_f4=round(skal_part_f4,.1)

replace skal_part_a5=round(skal_part_a5,.1)
replace skal_part_b5=round(skal_part_b5,.1)
replace skal_part_c5=round(skal_part_c5,.1)
replace skal_part_d5=round(skal_part_d5,.1)
replace skal_part_e5=round(skal_part_e5,.1)
replace skal_part_f5=round(skal_part_f5,.1)

replace skal_part_a6=round(skal_part_a6,.1)
replace skal_part_b6=round(skal_part_b6,.1)
replace skal_part_c6=round(skal_part_c6,.1)
replace skal_part_d6=round(skal_part_d6,.1)
replace skal_part_e6=round(skal_part_e6,.1)
replace skal_part_f6=round(skal_part_f6,.1)

replace skal_part_a7=round(skal_part_a7,.1)
replace skal_part_b7=round(skal_part_b7,.1)
replace skal_part_c7=round(skal_part_c7,.1)
replace skal_part_d7=round(skal_part_d7,.1)
replace skal_part_e7=round(skal_part_e7,.1)
replace skal_part_f7=round(skal_part_f7,.1)
tab1 skal_part_a7-skal_part_f7


tab1 skal_part_a1 skal_part_b1
gen skal_part_union1=skal_part_a1 if fedstate !=2
replace skal_part_union1=skal_part_b1 if fedstate ==2
gen skal_part_union2=skal_part_a2 if fedstate !=2
replace skal_part_union2=skal_part_b2 if fedstate ==2
gen skal_part_union3=skal_part_a3 if fedstate !=2
replace skal_part_union3=skal_part_b3 if fedstate ==2
gen skal_part_union4=skal_part_a4 if fedstate !=2
replace skal_part_union4=skal_part_b4 if fedstate ==2
gen skal_part_union5=skal_part_a5 if fedstate !=2
replace skal_part_union5=skal_part_b5 if fedstate ==2
gen skal_part_union6=skal_part_a6 if fedstate !=2
replace skal_part_union6=skal_part_b6 if fedstate ==2
gen skal_part_union7=skal_part_a7 if fedstate !=2
replace skal_part_union7=skal_part_b7 if fedstate ==2

egen maxskalo1h=rowmax(skal_part_union1 skal_part_c1 skal_part_d1 skal_part_e1 skal_part_f1)
egen maxskalo2h=rowmax(skal_part_union2 skal_part_c2 skal_part_d2 skal_part_e2 skal_part_f2)
egen maxskalo3h=rowmax(skal_part_union3 skal_part_c3 skal_part_d3 skal_part_e3 skal_part_f3)
egen maxskalo4h=rowmax(skal_part_union4 skal_part_c4 skal_part_d4 skal_part_e4 skal_part_f4)
egen maxskalo5h=rowmax(skal_part_union5 skal_part_c5 skal_part_d5 skal_part_e5 skal_part_f5)
egen maxskalo6h=rowmax(skal_part_union6 skal_part_c6 skal_part_d6 skal_part_e6 skal_part_f6)
egen maxskalo7h=rowmax(skal_part_union7 skal_part_c7 skal_part_d7 skal_part_e7 skal_part_f7)

replace maxskalo1=maxskalo1h
replace maxskalo2=maxskalo2h
replace maxskalo3=maxskalo3h
replace maxskalo4=maxskalo4h
replace maxskalo5=maxskalo5h
replace maxskalo6=maxskalo6h
replace maxskalo7=maxskalo7h
tab1 maxskalo1-maxskalo7

gen maxunion1=0
replace maxunion1=1 if maxskalo1==skal_part_union1
gen maxunion2=0
replace maxunion2=1 if maxskalo2==skal_part_union2
gen maxunion3=0
replace maxunion3=1 if maxskalo3==skal_part_union3
gen maxunion4=0
replace maxunion4=1 if maxskalo4==skal_part_union4
gen maxunion5=0
replace maxunion5=1 if maxskalo5==skal_part_union5
gen maxunion6=0
replace maxunion6=1 if maxskalo6==skal_part_union6
gen maxunion7=0
replace maxunion7=1 if maxskalo7==skal_part_union7

gen maxc1=0
replace maxc1=1 if maxskalo1==skal_part_c1
gen maxc2=0
replace maxc2=1 if maxskalo2==skal_part_c2
gen maxc3=0
replace maxc3=1 if maxskalo3==skal_part_c3
gen maxc4=0
replace maxc4=1 if maxskalo4==skal_part_c4
gen maxc5=0
replace maxc5=1 if maxskalo5==skal_part_c5
gen maxc6=0
replace maxc6=1 if maxskalo6==skal_part_c6
gen maxc7=0
replace maxc7=1 if maxskalo7==skal_part_c7

gen maxd1=0
replace maxd1=1 if maxskalo1==skal_part_d1
gen maxd2=0
replace maxd2=1 if maxskalo2==skal_part_d2
gen maxd3=0
replace maxd3=1 if maxskalo3==skal_part_d3
gen maxd4=0
replace maxd4=1 if maxskalo4==skal_part_d4
gen maxd5=0
replace maxd5=1 if maxskalo5==skal_part_d5
gen maxd6=0
replace maxd6=1 if maxskalo6==skal_part_d6
gen maxd7=0
replace maxd7=1 if maxskalo7==skal_part_d7

gen maxe1=0
replace maxe1=1 if maxskalo1==skal_part_e1
gen maxe2=0
replace maxe2=1 if maxskalo2==skal_part_e2
gen maxe3=0
replace maxe3=1 if maxskalo3==skal_part_e3
gen maxe4=0
replace maxe4=1 if maxskalo4==skal_part_e4
gen maxe5=0
replace maxe5=1 if maxskalo5==skal_part_e5
gen maxe6=0
replace maxe6=1 if maxskalo6==skal_part_e6
gen maxe7=0
replace maxe7=1 if maxskalo7==skal_part_e7

gen maxf1=0
replace maxf1=1 if maxskalo1==skal_part_f1
gen maxf2=0
replace maxf2=1 if maxskalo2==skal_part_f2
gen maxf3=0
replace maxf3=1 if maxskalo3==skal_part_f3
gen maxf4=0
replace maxf4=1 if maxskalo4==skal_part_f4
gen maxf5=0
replace maxf5=1 if maxskalo5==skal_part_f5
gen maxf6=0
replace maxf6=1 if maxskalo6==skal_part_f6
gen maxf7=0
replace maxf7=1 if maxskalo7==skal_part_f7

tab maxskalo1 skal_part_union1

* Indifference.
* without AfD and Pirates because of comparability with 2009.

egen max2skalo1c=rowmax(skal_part_c1 skal_part_d1 skal_part_e1 skal_part_f1) if maxunion1==1
egen max2skalo2c=rowmax(skal_part_c2 skal_part_d2 skal_part_e2 skal_part_f2) if maxunion1==1
egen max2skalo3c=rowmax(skal_part_c3 skal_part_d3 skal_part_e3 skal_part_f3) if maxunion1==1
egen max2skalo4c=rowmax(skal_part_c4 skal_part_d4 skal_part_e4 skal_part_f4) if maxunion1==1
egen max2skalo5c=rowmax(skal_part_c5 skal_part_d5 skal_part_e5 skal_part_f5) if maxunion1==1
egen max2skalo6c=rowmax(skal_part_c6 skal_part_d6 skal_part_e6 skal_part_f6) if maxunion1==1
egen max2skalo7c=rowmax(skal_part_c7 skal_part_d7 skal_part_e7 skal_part_f7) if maxunion1==1

egen max2skalo1s=rowmax(skal_part_union1 skal_part_d1 skal_part_e1 skal_part_f1) if maxc1==1
egen max2skalo2s=rowmax(skal_part_union2 skal_part_d2 skal_part_e2 skal_part_f2) if maxc1==1
egen max2skalo3s=rowmax(skal_part_union3 skal_part_d3 skal_part_e3 skal_part_f3) if maxc1==1
egen max2skalo4s=rowmax(skal_part_union4 skal_part_d4 skal_part_e4 skal_part_f4) if maxc1==1
egen max2skalo5s=rowmax(skal_part_union5 skal_part_d5 skal_part_e5 skal_part_f5) if maxc1==1
egen max2skalo6s=rowmax(skal_part_union6 skal_part_d6 skal_part_e6 skal_part_f6) if maxc1==1
egen max2skalo7s=rowmax(skal_part_union7 skal_part_d7 skal_part_e7 skal_part_f7) if maxc1==1

egen max2skalo1f=rowmax(skal_part_union1 skal_part_c1 skal_part_e1 skal_part_f1) if maxd1==1
egen max2skalo2f=rowmax(skal_part_union2 skal_part_c2 skal_part_e2 skal_part_f2) if maxd1==1
egen max2skalo3f=rowmax(skal_part_union3 skal_part_c3 skal_part_e3 skal_part_f3) if maxd1==1
egen max2skalo4f=rowmax(skal_part_union4 skal_part_c4 skal_part_e4 skal_part_f4) if maxd1==1
egen max2skalo5f=rowmax(skal_part_union5 skal_part_c5 skal_part_e5 skal_part_f5) if maxd1==1
egen max2skalo6f=rowmax(skal_part_union6 skal_part_c6 skal_part_e6 skal_part_f6) if maxd1==1
egen max2skalo7f=rowmax(skal_part_union7 skal_part_c7 skal_part_e7 skal_part_f7) if maxd1==1

egen max2skalo1g=rowmax(skal_part_union1 skal_part_d1 skal_part_c1 skal_part_f1) if maxe1==1
egen max2skalo2g=rowmax(skal_part_union2 skal_part_d2 skal_part_c2 skal_part_f2) if maxe1==1
egen max2skalo3g=rowmax(skal_part_union3 skal_part_d3 skal_part_c3 skal_part_f3) if maxe1==1
egen max2skalo4g=rowmax(skal_part_union4 skal_part_d4 skal_part_c4 skal_part_f4) if maxe1==1
egen max2skalo5g=rowmax(skal_part_union5 skal_part_d5 skal_part_c5 skal_part_f5) if maxe1==1
egen max2skalo6g=rowmax(skal_part_union6 skal_part_d6 skal_part_c6 skal_part_f6) if maxe1==1
egen max2skalo7g=rowmax(skal_part_union7 skal_part_d7 skal_part_c7 skal_part_f7) if maxe1==1

egen max2skalo1l=rowmax(skal_part_union1 skal_part_d1 skal_part_c1 skal_part_e1) if maxf1==1
egen max2skalo2l=rowmax(skal_part_union2 skal_part_d2 skal_part_c2 skal_part_e2) if maxf1==1
egen max2skalo3l=rowmax(skal_part_union3 skal_part_d3 skal_part_c3 skal_part_e3) if maxf1==1
egen max2skalo4l=rowmax(skal_part_union4 skal_part_d4 skal_part_c4 skal_part_e4) if maxf1==1
egen max2skalo5l=rowmax(skal_part_union5 skal_part_d5 skal_part_c5 skal_part_e5) if maxf1==1
egen max2skalo6l=rowmax(skal_part_union6 skal_part_d6 skal_part_c6 skal_part_e6) if maxf1==1
egen max2skalo7l=rowmax(skal_part_union7 skal_part_d7 skal_part_c7 skal_part_e7) if maxf1==1

tab1 max2skalo1c-max2skalo7l

gen indiff1= 1-(maxskalo1-max2skalo1c) if maxunion1==1
replace indiff1= 1-(maxskalo1-max2skalo1s) if maxc1==1
replace indiff1= 1-(maxskalo1-max2skalo1f) if maxd1==1
replace indiff1= 1-(maxskalo1-max2skalo1g) if maxe1==1
replace indiff1= 1-(maxskalo1-max2skalo1l) if maxf1==1
replace indiff1=round(indiff1,.1)
tab indiff1

gen indiff2= 1-(maxskalo2-max2skalo2c) if maxunion2==1
replace indiff2= 1-(maxskalo2-max2skalo2s) if maxc2==1
replace indiff2= 1-(maxskalo2-max2skalo2f) if maxd2==1
replace indiff2= 1-(maxskalo2-max2skalo2g) if maxe2==1
replace indiff2= 1-(maxskalo2-max2skalo2l) if maxf2==1
replace indiff2=round(indiff2,.1)

gen indiff3= 1-(maxskalo3-max2skalo3c) if maxunion3==1
replace indiff3= 1-(maxskalo3-max2skalo3s) if maxc3==1
replace indiff3= 1-(maxskalo3-max2skalo3f) if maxd3==1
replace indiff3= 1-(maxskalo3-max2skalo3g) if maxe3==1
replace indiff3= 1-(maxskalo3-max2skalo3l) if maxf3==1
replace indiff3=round(indiff3,.1)

gen indiff4= 1-(maxskalo4-max2skalo4c) if maxunion4==1
replace indiff4= 1-(maxskalo4-max2skalo4s) if maxc4==1
replace indiff4= 1-(maxskalo4-max2skalo4f) if maxd4==1
replace indiff4= 1-(maxskalo4-max2skalo4g) if maxe4==1
replace indiff4= 1-(maxskalo4-max2skalo4l) if maxf4==1
replace indiff4=round(indiff4,.1)

gen indiff5= 1-(maxskalo5-max2skalo5c) if maxunion5==1
replace indiff5= 1-(maxskalo5-max2skalo5s) if maxc5==1
replace indiff5= 1-(maxskalo5-max2skalo5f) if maxd5==1
replace indiff5= 1-(maxskalo5-max2skalo5g) if maxe5==1
replace indiff5= 1-(maxskalo5-max2skalo5l) if maxf5==1
replace indiff5=round(indiff5,.1)

gen indiff6= 1-(maxskalo6-max2skalo6c) if maxunion6==1
replace indiff6= 1-(maxskalo6-max2skalo6s) if maxc6==1
replace indiff6= 1-(maxskalo6-max2skalo6f) if maxd6==1
replace indiff6= 1-(maxskalo6-max2skalo6g) if maxe6==1
replace indiff6= 1-(maxskalo6-max2skalo6l) if maxf6==1
replace indiff6=round(indiff6,.1)

gen indiff7= 1-(maxskalo7-max2skalo7c) if maxunion7==1
replace indiff7= 1-(maxskalo7-max2skalo7s) if maxc7==1
replace indiff7= 1-(maxskalo7-max2skalo7f) if maxd7==1
replace indiff7= 1-(maxskalo7-max2skalo7g) if maxe7==1
replace indiff7= 1-(maxskalo7-max2skalo7l) if maxf7==1
replace indiff7=round(indiff7,.1)

tab1 indiff1-indiff7

* Alienation
* Without AfD and Pirates, see above.

generate entfremd1=(((skal_part_union1+skal_part_c1+skal_part_d1+skal_part_e1+skal_part_f1)/-5)+1)
generate entfremd2=(((skal_part_union2+skal_part_c2+skal_part_d2+skal_part_e2+skal_part_f2)/-5)+1)
generate entfremd3=(((skal_part_union3+skal_part_c3+skal_part_d3+skal_part_e3+skal_part_f3)/-5)+1)
generate entfremd4=(((skal_part_union4+skal_part_c4+skal_part_d4+skal_part_e4+skal_part_f4)/-5)+1)
generate entfremd5=(((skal_part_union5+skal_part_c5+skal_part_d5+skal_part_e5+skal_part_f5)/-5)+1)
generate entfremd6=(((skal_part_union6+skal_part_c6+skal_part_d6+skal_part_e6+skal_part_f6)/-5)+1)
generate entfremd7=(((skal_part_union7+skal_part_c7+skal_part_d7+skal_part_e7+skal_part_f7)/-5)+1)
tab1 entfremd1-entfremd7

generate entfremda1=(maxskalo1-1)*-1
generate entfremda2=(maxskalo2-1)*-1
generate entfremda3=(maxskalo3-1)*-1
generate entfremda4=(maxskalo4-1)*-1
generate entfremda5=(maxskalo5-1)*-1
generate entfremda6=(maxskalo6-1)*-1
generate entfremda7=(maxskalo7-1)*-1
tab1 entfremda1-entfremda7



keep lfdn wkampfint? intefficacy? extefficacy? zufr? indiff? ///
	entfremda? 
	
save "${path}\Reproducible Do-Files\Chapter 5\Data\attitudes09.dta", replace
